package dssd.gui;

import java.awt.event.ActionEvent;
import javax.swing.*;

import org.jdesktop.layout.GroupLayout;
import org.jdesktop.layout.LayoutStyle;

import dssd.gui.ConsultarInfracciones;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaPrincipal extends javax.swing.JFrame {

	private JPanel jPanel1;
	
	private JMenuBar jMenuBar1;

	private JMenu jMenu5;
	private JMenu jMenuSolicitudes;
	private JMenuItem jMenuItemInfraccionesConsultar;

	private JMenuItem jMenuItemVerAltas;
	private JMenuItem jMenuItemVerRenovaciones;
	
	private JMenuItem helpMenuItem;
	private JMenu jMenuInfraccion;
	private JMenuItem jMenuItemFinalizadas;

	private AbstractAction accionVerAltas;
	private AbstractAction accionVerRenovaciones;
	private AbstractAction accionVerFinalizadas;
	private AbstractAction accionConsultaInfracciones;
	JMenuItem altaMenuItem;
	JMenuItem renovacionMenuItem;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VentanaPrincipal inst = new VentanaPrincipal();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaPrincipal() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			setSize(400, 300);
			{
				jPanel1 = new JPanel();
				GroupLayout jPanel1Layout = new GroupLayout((JComponent)jPanel1);
				jPanel1.setLayout(jPanel1Layout);
				
				jMenuBar1 = new JMenuBar();
				setJMenuBar(jMenuBar1);
				{
					jMenu5 = new JMenu();
					jMenuBar1.add(jMenu5);
					jMenu5.setText("Archivo");
					{
						helpMenuItem = new JMenuItem();
						jMenu5.add(helpMenuItem);
						helpMenuItem.setText("Salir");
						helpMenuItem.setAction(
								new AbstractAction("Salir", null) {
									public void actionPerformed(ActionEvent evt) {
										cerrar();
									}});
					}
				}
				{
					jMenuBar1.add(getjMenuSolicitudes());
					jMenuBar1.add(getJMenuInfraccion());
				}
				jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup()
						.addContainerGap(73, 73)
						.add(jPanel1Layout.createParallelGroup()
						    .add(GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()
						        .add(0, 0, Short.MAX_VALUE)
						        .add(54)))
						.add(28)
						.add(jPanel1Layout.createParallelGroup()
						    .add(jPanel1Layout.createSequentialGroup()
						        .add(jPanel1Layout.createParallelGroup()
						            .add(GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()
						                .add(79))
						            .add(GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()
						                .add(0, 72, GroupLayout.PREFERRED_SIZE)))
						        .add(34)))
						.addContainerGap());				
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private JMenu getjMenuSolicitudes() {
		if(jMenuSolicitudes == null) {
			jMenuSolicitudes = new JMenu();
			jMenuSolicitudes.setText("Solicitudes");
			jMenuSolicitudes.add(getJMenuItemVerAltas());
			jMenuSolicitudes.add(getJMenuItemVerRenovaciones());
			jMenuSolicitudes.add(getJMenuItemFinalizadas());
		}
		return jMenuSolicitudes;
	}

	private JMenuItem getJMenuItemVerAltas() {
		if(jMenuItemVerAltas == null) {
			jMenuItemVerAltas = new JMenuItem();
			jMenuItemVerAltas.setAction(getAccionVerAltas() );
		}
		return jMenuItemVerAltas;
	}
	
	private JMenuItem getJMenuItemVerRenovaciones() {
		if(jMenuItemVerRenovaciones == null) {
			jMenuItemVerRenovaciones = new JMenuItem();
			jMenuItemVerRenovaciones.setAction(getAccionVerRenovaciones() );
		}
		return jMenuItemVerRenovaciones;
	}
	
	private JMenuItem getJMenuItemFinalizadas() {
		if(jMenuItemFinalizadas == null) {
			jMenuItemFinalizadas = new JMenuItem();
			jMenuItemFinalizadas.setText("Finalizadas");
			jMenuItemFinalizadas.setAction(getAccionVerFinalizadas());
		}
		return jMenuItemFinalizadas;
	}

	private AbstractAction getAccionVerAltas() {
		if(accionVerAltas == null) {
			accionVerAltas = new AbstractAction("Alta", null) {
				public void actionPerformed(ActionEvent evt) {
					VerSolicitudesAlta bspd = new VerSolicitudesAlta();
					bspd.setVisible(true);
				}
			};
		}
		return accionVerAltas;
	}
	
	private AbstractAction getAccionVerRenovaciones() {
		if(accionVerRenovaciones == null) {
			accionVerRenovaciones = new AbstractAction("Renovacion", null) {
				public void actionPerformed(ActionEvent evt) {
					VerSolicitudesRenovacion bspd = new VerSolicitudesRenovacion();
					bspd.setVisible(true);
				}
			};
		}
		return accionVerRenovaciones;
	}
	
	private AbstractAction getAccionVerFinalizadas() {
		if(accionVerFinalizadas == null) {
			accionVerFinalizadas = new AbstractAction("Finalizadas", null) {
				public void actionPerformed(ActionEvent evt) {
					VerSolicitudesFinalizadas bspd = new VerSolicitudesFinalizadas();
					bspd.setVisible(true);
				}
			};
		}
		return accionVerFinalizadas;
	}
	
	public void cerrar(){
		this.setVisible(false);
	}
	
	private JMenu getJMenuInfraccion() {
		if(jMenuInfraccion == null) {
			jMenuInfraccion = new JMenu();
			jMenuInfraccion.setText("Infracciones");
			jMenuInfraccion.add(getJMenuItemInfraccionesConsultar());
		}
		return jMenuInfraccion;
	}
	
	private AbstractAction getAccionConsultarInfracciones(){
		if (accionConsultaInfracciones == null){
			accionConsultaInfracciones = new AbstractAction("Consultar",null) {
				public void actionPerformed(ActionEvent evt){
					ConsultarInfracciones bspd = new ConsultarInfracciones(); 
					bspd.setVisible(true);
				}
			};
		}
		return accionConsultaInfracciones;
	}

	private JMenuItem getJMenuItemInfraccionesConsultar() {
		if(jMenuItemInfraccionesConsultar == null) {
			jMenuItemInfraccionesConsultar = new JMenuItem();
			jMenuItemInfraccionesConsultar.setText("Consultar");
			jMenuItemInfraccionesConsultar.setAction(getAccionConsultarInfracciones());
		}
		return jMenuItemInfraccionesConsultar;
	}

}
